package com.studystack.studyme;
import java.util.Random;


/**
 * @author John Weidner
 */
public class StudyStack
{
    private String name ;
    private String description ;
    private String [][] cards;
    private String [] flaps ;
    private int numCards = 0;
    private static Random random = new Random( System.currentTimeMillis() );
    
    
    public StudyStack( String name )
    {
        this( name, "", new String[0], 0 );
    }
    
    public StudyStack( String name, String description, String [] flaps, int maxCards )
    {
        this.name = name ;
        this.description = description ;
        this.flaps = flaps ;
        this.cards = new String[maxCards][flaps.length];
        this.numCards = 0;
    }
    
    
    public void addCardData( String[] cardData )
    {
        cards[ numCards ] = cardData ;
        numCards ++;
    }
    
    public String getName() 
    {
        return name ;
    }
    
    public String getDescription()
    {
        return description ;
    }
    
    public String [] getFlaps()
    {
        return flaps ;
    }
    
    public String [] getCardData( int card )
    {
        return cards[ card ];
    }
    
    public int getNumCards()
    {
        return numCards ;
    }
    
    public static int getRandom( int bound ) 
    {  // return a random, positive integer less than bound
        return Math.abs( random.nextInt() % bound );
    }
    

    public void shuffle()
    {
        for ( int card = 0; card<numCards; card++ ) {
            int randomCard = getRandom( numCards ) ;
            String [] tmp = getCardData( randomCard );
            cards[ randomCard ] = cards[ card ];
            cards[ card ] = tmp ;
        }
    }
}
